package com.example.appkcsj.slice;

import com.example.appkcsj.DAO.FamilyDao;
import com.example.appkcsj.DAO.FamilyDaoImpl;
import com.example.appkcsj.ResourceTable;
import com.example.appkcsj.entity.Family;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.TextField;

public class ninthAbilitySlice extends AbilitySlice {
    private TextField t,t1;
    private Button b;
    private FamilyDao familyDao;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_ninth);
        familyDao = new FamilyDaoImpl(this);
//        dbUtils1=new DBUtils1(seventhAbilitySlice.this);
        b = (Button) findComponentById(ResourceTable.Id_but12);
        t = (TextField) findComponentById(ResourceTable.Id_field14);
        t1 = (TextField) findComponentById(ResourceTable.Id_textField2);
        b.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
//                Family family=dbUtils1.queryOneFamily();
                boolean family = familyDao.deleteByName(t.getText());

                if (family) {
                    //HiLog.info(HI_LOG_LABEL,"查询数据"+family);
                    Intent n=new Intent();
                    Operation operation=new Intent.OperationBuilder()
                            .withDeviceId("")
                            .withBundleName("com.example.appkcsj")//跳转到哪个应用
                            .withAbilityName("com.example.appkcsj.tenthAbility")//要跳转的包名
                            .build();//将上面的信息打包
                    n.setOperation(operation);
                    startAbility(n);
                }
            }
        });

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
